﻿using BLL;
using BookModel;
using CCWin;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;



namespace WinFromBook
{
    public partial class FrmUndefined : CCSkinMain
    {
        public FrmUndefined()
        {
            InitializeComponent();
        }

        //定义全局变量，保存ID
        public int BorrowerID { get; set; }
        public FrmReaderInfo Fr { get; set; }

        //窗体加载事件
        private void FrmUndefined_Load(object sender, EventArgs e)
        {
            DataTable dt = new borrowerIfnoBLL().SelectDamages(BorrowerID);
            foreach (DataRow  item in dt.Rows)
            {
                textBorrowerID.Text = item["BorrowerID"]+ "";
                textBname.Text = item["Bname"]+"";
                textReaderName.Text=item["ReaderName"]+"";
                textDamages.Text = item["BPrice"] + "";
            }
        }

        private void skinbtnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

       //点击确认事件
        private void skinButtonAdd_Click(object sender, EventArgs e)
        {
            if (textDamages.Text.Trim()=="")
            {
                MessageBox.Show("请输入赔偿金额！！","系统提示");
                return;
            }
            borrowerIfno bi = new borrowerIfno()
            {
                BorrowerID=int.Parse(textBorrowerID.Text.Trim()),
                BorrowerMake = "已赔偿",
                Borrowerremark="已赔偿金额："+textDamages.Text.Trim()+"元"
            };
            string sql = new BLL.borrowerIfnoBLL().updateBorrwer(bi);
            MessageBox.Show(sql,"系统提示");
            Fr.selectborrwer();
            this.Close();
        }

        //输入控制
        private void textDamages_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((e.KeyChar >= '0' && e.KeyChar <= '9') || e.KeyChar == '.' || e.KeyChar == 8)
            {
                e.Handled = false;
            }
            else
                e.Handled = true;

        }
    }
}
